$execute unless data storage dab:system gameRule[$(SG)] run return run function dab:system/ui/gamerules/toggle_gamerule_fai

#toggle
$execute store result score #ui.gr.tg.bool temp run data get storage dab:system gameRule[$(SG)].switch
$execute if score #ui.gr.tg.bool temp matches 1 run data modify storage dab:system gameRule[$(SG)].switch set value false
$execute if score #ui.gr.tg.bool temp matches 0 run data modify storage dab:system gameRule[$(SG)].switch set value true

playsound block.note_block.pling master @a

$execute if score #ui.gr.tg.bool temp matches 1 run tellraw @a [{"text": "[游戏规则] ","color": "yellow"},{"color": "#7fe0e7","text": "","extra": [{"nbt": "gameRule[$(SG)].display.name","storage": "dab:system","interpret": true}]},{"text": "已禁用！","color": "red"}]
$execute if score #ui.gr.tg.bool temp matches 0 run tellraw @a [{"text": "[游戏规则] ","color": "yellow"},{"color": "#7fe0e7","text": "","extra": [{"nbt": "gameRule[$(SG)].display.name","storage": "dab:system","interpret": true}]},{"text": "已启用！","color": "green"}]
# execute if score #ui.gr.tg.bool temp matches 0 run execute as @a at @s run playsound entity.generic.explode master @a ~ ~ ~ 0.3
# execute if score #ui.gr.tg.bool temp matches 0 run particle smoke ~ ~ ~ 0.3 0.3 0.3 0.2 5 normal
# execute if score #ui.gr.tg.bool temp matches 0 run particle explosion ~ ~0.3 ~ 0 0.1 0 1 1 normal
# execute if score #ui.gr.tg.bool temp matches 0 run particle cloud ~ ~ ~ 0.3 0.3 0.3 0.3 20 normal

$function dab:system/ui/gamerules/update_display {SG:$(SG)}

scoreboard players reset #ui.gr.tg.bool temp